import Vue from 'vue'
import Router from 'vue-router'
const Login = () => import('../components/Login')
const Mobile = () => import('../components/Mobile')
const HomePage = () => import('../components/HomePage')
const Activity = () => import('../components/Activity')
const Student = () => import('../components/Student')
const ActivityContent = () => import('../components/ActivityContent')
const User = () => import('../components/User')
const Manager = () => import('../components/Manager')
const Moment = () => import('../components/Moment')

Vue.use(Router)
Vue.use(Router)
//防止跳转相同路由报错
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
};

export default new Router({
  routes: [
    {
      path: '/login',
      name: 'login',
      component: Login
    },
    {
      path: '/mobile',
      name: 'mobile',
      component: Mobile
    },
    {
      path: '/homePage',
      component: HomePage,
      //有默认子路由，父路由要去掉name，不然会有警告
      children: [
        //默认显示路径
        {
          path: '',
          redirect: 'activity'
        },
        {
          path: 'activity',
          component: Activity
        },
        {
          path: 'student',
          component: Student
        },
        {
          path: 'activityContent',
          component: ActivityContent
        },
        {
          path: 'user',
          component: User
        },
        {
          path: 'manager',
          component: Manager
        },
        {
          path: 'moment',
          component: Moment
        },

      ]
    },
  ]
})
